<?php

namespace app\mobile\controller;

use think\Db;
use clt\Leftnav;
use think\Controller;
use controller\BasicMobile;
use think\Request;
use think\Config;
use think\Debug;

class Common extends BasicMobile{

    protected $pagesize,$changyan,$new_aid;

    function __construct(Request $request = null)
    {      
          
        parent::__construct($request);
    // public function _initialize(){
        //Debug::remark('begin');
        //地区id
        $aid = $this->new_aid = $this->aid;
        //获取各个站点的站点信息
        $domainInfo = Db::name('Domain')->where(['zone_id' =>$aid ,'status'=>0])->find();
        $this->assign('domainInfo',$domainInfo);
        //halt($domainInfo);
        
        // if($this->aid == 1){
        //     $aidArr = [1];
        //     $aids = $this->area->getColumn(['area_parent_id' => 1], 'area_id');
        //     $aidArr = array_merge($aidArr, $aids);
        //     // halt($aidArr);     
        //     $aid = $this->new_aid = ['in', $aidArr];
        // }
        // halt($aid); 

        //获取控制方法
        $action = strtolower($this->action);
        $controller = strtolower($this->controller);
        $this->assign('action',$action);
        $this->assign('controller',$controller);
        define('ACTION_NAME',$action);
        define('MODULE_NAME',$controller);

        //获取所有栏目导航(单条数据)
        if($controller=='rcpx'){
          //当前调用的数据库
          // $this->categorypx = $this->databasepx->name('category');
          // $thisCat = $this->categorypx->where(['id'=>input('catId'),'ismenu'=>1])->find();
          $this->db = $this->databasepx;
          $this->category = $this->categorypx;
        }elseif($controller=='ppjs'){
          // $this->categorypp = $this->databasepp->name('category');
          // $thisCat = $this->categorypp->where(['id'=>input('catId'),'ismenu'=>1])->find();
          $this->db = $this->databasepp;
          $this->category = $this->categorypp;
        }elseif($controller=='dsfp'){
          // $this->categoryfp = $this->databasefp->name('category');
          // $thisCat = $this->categoryfp->where(['id'=>input('catId'),'ismenu'=>1])->find();
          $this->db = $this->databasefp;
          $this->category = $this->categoryfp;
        }else{
          // $this->category = $this->databasefw->name('category');
          // $thisCat = $this->category->where(['id'=>input('catId'),'ismenu'=>1])->find();
          $this->db = $this->databasefw;
          $this->category = $this->categoryfw;
          // $this->dao = $this->databasefw->name(DBNAME);//默认数据源：公共服务系统
        }

        $thisCat = $this->category->where(['id'=>input('catId'),'ismenu'=>1])->find();
        $this->assign('thisCat',$thisCat);
        $this->assign('title',$thisCat['title']);
        $this->assign('keywords',$thisCat['keywords']);
        $this->assign('description',$thisCat['description']);
        $this->pagesize = $thisCat['pagesize']>0 ? $thisCat['pagesize'] : '';
        define('DBNAME',strtolower($thisCat['module']));
        $this->dao = $this->db->name(DBNAME);

        // 获取缓存所有栏目导航数据(多条数据)
        //$this->cate = cache('cate');
        //halt($this->cate);
        if(!$this->cate){
            $column_one = $this->categoryfw->where(['parentid'=>0,'ismenu'=>1])->order('sort asc,id asc')->select();
            $column_onepp = $this->categorypp->where(['id' => 3000,'parentid'=>0,'ismenu'=>1])->order('sort asc,id asc')->select();
            $column_onepx = $this->categorypx->where(['id' => 1000,'parentid'=>0,'ismenu'=>1])->order('sort asc,id asc')->select();            
            $column_onefp = $this->categoryfp->where(['id' => 2000,'parentid'=>0,'ismenu'=>1])->order('sort asc,id asc')->select();

            if($column_onepp){
                $column_onepp[0]['sort'] = 6;
                $column_one = array_merge($column_one, $column_onepp); 
                $column_twopp = $this->categorypp->where(['parentid'=>$column_onepp[0]['id'],'ismenu'=>1])->order('sort asc,id asc')->select();  
            }
            if($column_onepx){
                $column_onepx[0]['sort'] = 9;
                $column_one = array_merge($column_one, $column_onepx); 
                $column_twopx = $this->categorypx->where(['parentid'=>$column_onepx[0]['id'],'ismenu'=>1])->order('sort asc,id asc')->select();               
            }
            if($column_onefp){
                $column_onefp[0]['sort'] = 3;
                $column_one = array_merge($column_one, $column_onefp); 
                $column_twofp = $this->categoryfp->where(['parentid'=>$column_onefp[0]['id'],'ismenu'=>1])->order('sort asc,id asc')->select();  
            }

            foreach($column_one as $list2){
                $sort[]=$list2["sort"];
            }
            array_multisort($sort,SORT_ASC,$column_one);
            // halt($column_twopp);

            $column_two = $this->categoryfw->where('ismenu',1)->order('sort asc,id asc')->select();
            // // $column_twopp = $this->categorypp->where(['ismenu'=>1])->order('sort asc,id asc')->select();
            // $column_twopx = $this->categorypx->where(['id' => 1000,'ismenu'=>1])->order('sort asc,id asc')->select();
            $column_two = array_merge($column_two, $column_twopp, $column_twopx, $column_twofp);
            // halt($column_two);
            $tree = new Leftnav ();
            $this->cate = $tree->index_top($column_one,$column_two,$this->aid);
            // $this->catepx = $tree->index_top_px($column_onepx,$column_twopx,$this->aid);
            //cache('cate', $this->cate, 3600);
        }
        // Debug::remark('end');echo Debug::getRangeTime('begin','end').'s';die;
        //halt($this->cate);
        $this->assign('category',$this->cate);
        // $this->assign('categorypx',$this->catepx);

        //获取当前页面父级栏目导航数据
        $parentCat = $this->category->where(['parentid'=>0,'ismenu'=>1,'catdir'=>MODULE_NAME])->order('sort asc,id asc')->find();
        $this->assign('parentCat',$parentCat);

        //获取当前页面子级栏目导航数据
        $where['parentid'] = array('neq',0);
        $where['ismenu'] = array('eq',1);
        $where['parentdir'] = array('eq',MODULE_NAME.'/');
        $childCat = $this->category->where($where)->order('sort asc,id asc')->select();
        $this->assign('childCat',$childCat);
        //halt($childCat);

        //16th Nov, 2018 By pp 下级地区数据提取条件
        $this->map1 = [];
        $val = switchArDeep($this->aid);
        if($val){
            $this->map1['aid'] = ['in', $this->aids];
            $this->map1[$val] = 1;//对应推送字段
            $this->map1['status'] = 1;
        }
        $map1 = $this->map1;

        //文章首页推荐
        $index_posid = $this->db
                ->name('article')
                ->alias('a')
                ->join(config('database.prefix').'category c','a.catid = c.id','left')
                ->where(['posid'=>1,'aid'=>$aid,'status'=>1])
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                    // ->fetchSql(true)
                ->field('a.*,c.catdir')
                ->limit('10')
                ->order('sort asc,updatetime desc')
                ->select();
        // halt($index_posid);
        $this->assign('index_posid',$index_posid);

        //文章首页通知公告
        $index_tzgg = $this->db
                ->name('article')
                ->alias('a')
                ->join(config('database.prefix').'category c','a.catid = c.id','left')
                ->where(['aid'=>$aid,'status'=>1])
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->field('a.*,c.catdir')
                ->limit('10')
                ->order('updatetime desc')
                ->select();
        //halt($index_tzgg);
        $this->assign('index_tzgg',$index_tzgg);

        //文章热门推荐
        $arrchildid = $this->db->name('category')->where(['id'=>input('catId')])->value('arrchildid');
        $hotMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        if($arrchildid!=input('catId')){
            $catId = ['in',$arrchildid];
        }else{
            $catId = input("catId");
        }
        $hotMap['catId'] = $catId;
        $hotMap['posid'] = 2;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $hotMap;
        $hot_posid = $this->db
                ->name('article')
                ->where($hotMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->limit('10')
                ->select();
        $this->assign('hot_posid',$hot_posid);
        // halt($hot_posid);

        //文章相关推荐
        $relMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        if($arrchildid!=input('catId')){
            $catId = ['in',$arrchildid];
        }else{
            $catId = input("catId");
        }
        $relMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $relMap;
        $relevant_posid = $this->db
                ->name('article')
                ->where($relMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->limit('10')
                ->select();
        $this->assign('relevant_posid',$relevant_posid);
        //halt($relevant_posid);
       
        //公共政务(频道页)
        //公共政务(子栏目所有文章)
        $catId = array('in','2,3,4,5');
        $ggzwmap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $ggzwmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ggzwmap;
        $ggzw = $this->databasefw
                ->name('article')
                ->where($ggzwmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ggzw',$ggzw);
        //办事指南
        $catId = 2;
        $ggzwmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ggzwmap;
        $bszn = $this->databasefw
                ->name('article')
                ->where($ggzwmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('bszn',$bszn);
        // halt($bszn);
        //办事指南置顶
        $bszntopmap = $ggzwmap;
        $bszntopmap['posid'] = 3;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $bszntopmap;
        $bsznTopPosid = $this->databasefw
                ->name('article')
                ->where($bszntopmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->find();
        $this->assign('bsznTopPosid',$bsznTopPosid);
        //产业政策
        $catId = 4;
        $ggzwmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ggzwmap;
        $cyzc = $this->databasefw
                ->name('article')
                ->where($ggzwmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cyzc',$cyzc);
        //公告公示
        $catId = 5;
        $ggzwmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ggzwmap;
        $gggs = $this->databasefw
                ->name('article')
                ->where($ggzwmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('gggs',$gggs);
        //服务项目
        $catId = 3;
        $ggzwmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ggzwmap;
        $fwxm = $this->databasefw
                ->name('article')
                ->where($ggzwmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('fwxm',$fwxm);
        //halt($fwxm);

        //产业资讯(频道页)
        //产业资讯(子栏目所有文章)
        $cyzxmap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $cyzxmap['catId'] = array('in','12,13,14,15');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cyzxmap;
        $cyzx = $this->databasefw
                ->name('article')
                ->where($cyzxmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cyzx',$cyzx);
        //行业资讯
        $catId = 12;
        $cyzxmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cyzxmap;
        $hyzx = $this->databasefw
                ->name('article')
                ->where($cyzxmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('hyzx',$hyzx);
        //行业资讯置顶
        $hyzxtopmap = $cyzxmap;
        $hyzxtopmap['posid'] = 3;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $hyzxtopmap;
        $hyzxTopPosid = $this->databasefw
                ->name('article')
                ->where($hyzxtopmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->find();
        $this->assign('hyzxTopPosid',$hyzxTopPosid);
        //halt($hyzx);
        //权威发布  
        $catId = 15;
        $cyzxmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cyzxmap;
        $qwfb = $this->databasefw
                ->name('article')
                ->where($cyzxmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('qwfb',$qwfb);
        //权威发布置顶
        $qwfbtopmap = $cyzxmap;
        $qwfbtopmap['posid'] = 3;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $qwfbtopmap;
        $qwfbTopPosid = $this->databasefw
                ->name('article')
                ->where($qwfbtopmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->find();
        $this->assign('qwfbTopPosid',$qwfbTopPosid);
        //企业新闻
        $catId = 14;
        $cyzxmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cyzxmap;
        $qyxw = $this->databasefw
                ->name('article')
                ->where($cyzxmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('qyxw',$qyxw);
        //企业新闻置顶
        $qyxwtopmap = $cyzxmap;
        $qyxwtopmap['posid'] = 3;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $qyxwtopmap;
        $qyxwTopPosid = $this->databasefw
                ->name('article')
                ->where($qyxwtopmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->find();
        $this->assign('qyxwTopPosid',$qyxwTopPosid);
        //县域电商
        $catId = 13;
        $cyzxmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cyzxmap;
        $xyds = $this->databasefw
                ->name('article')
                ->where($cyzxmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('xyds',$xyds);

        //服务站点(频道页)
        //站点简介
        $catId = 7;
        $fwzdmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $fwzdmap;
        $fwzdJj = $this->databasefw
                ->name('article')
                ->where($fwzdmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('fwzdJj',$fwzdJj);
        //下级站点信息
        $catId = 8;
        $fwzdmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $fwzdmap;
        $fwzdXjzd = $this->databasefw
                ->name('article')
                ->where($fwzdmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('fwzdXjzd',$fwzdXjzd);

        //产销对接(频道页)
        //产销对接(子栏目所有文章)
        $cxdjmap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $cxdjmap['catId'] = array('in','32,33,50,51,52,53,54');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxdjmap;
        $cxdj = $this->databasefw
                ->name('article')
                ->where($cxdjmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxdj',$cxdj);
        //halt($cxdj);
        //供求信息
        $catId = 33;
        $cxdjmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxdjmap;
        $gqxx = $this->databasefw
                ->name('article')
                ->where($cxdjmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('gqxx',$gqxx);
        
        //入驻企业
        $catId = 32;
        $cxdjmap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxdjmap;
        $rzqy = $this->databasefw
                ->name('article')
                ->where($cxdjmap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('rzqy',$rzqy);

        //特色产品分类
        $tscpCat = $this->category
                ->where(['parentid'=>34,'ismenu'=>1])
                ->order('sort asc,id asc')
                ->select();
        $this->assign('tscpCat',$tscpCat);
        //特色产品
        $tscpMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $tscpMap['catId'] = array('in','50,51,51,52,53');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscp = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscp',$tscp);
        //特色产品-水果
        $catId = 50;
        $tscpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscpShuiGuo = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscpShuiGuo',$tscpShuiGuo);
        //特色产品-蔬菜
        $catId = 51;
        $tscpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscpShuCai = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscpShuCai',$tscpShuCai);
        //特色产品-美食
        $catId = 52;
        $tscpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscpMeiShi = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscpMeiShi',$tscpMeiShi);
        //特色产品-工艺
        $catId = 53;
        $tscpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscpGongYi = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscpGongYi',$tscpGongYi);
        //特色产品-其他
        $catId = 54;
        $tscpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $tscpMap;
        $tscpQiTa = $this->databasefw
                ->name('article')
                ->where($tscpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tscpQiTa',$tscpQiTa);

        //旅游文化(频道页)
        //旅游文化(子栏目所有文章)
        $lywhMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $lywhMap['catId'] = array('in','35,36,37,56');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $lywh = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('lywh',$lywh);
        //简介
        $catId = 55;
        $lywhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $introduction = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('introduction',$introduction);
        //旅游景点
        $catId = 35;
        $lywhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $lyjd = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('lyjd',$lyjd);
        //路线攻略
        $catId = 36;
        $lywhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $lxgl = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('lxgl',$lxgl);
        //特色美食
        $catId = 56;
        $lywhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $tsms = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('tsms',$tsms);
        //旅游动态
        $catId = 37;
        $lywhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $lywhMap;
        $lydt = $this->databasefw
                ->name('article')
                ->where($lywhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('lydt',$lydt);

        //大理州-旅游文化(频道页)
        //旅游景点
        // $subpAreas = $this->area->getLists(['area_parent_id' => 1], 'area_sort asc', 'area_id,area_name');
        // $lyjd_zhou = [];
        // foreach ($subpAreas as $k => $v) {
        //     $lyjd_zhou[$k] = $v;
        //     $lyjd_zhou[$k]['sup'] = $this->databasefw->name('article')->where(['status'=>1,'catId'=>35,'aid'=>$v['area_id']])->order('sort asc,updatetime desc')->select();

        //     $domainInfo = get_domain('zone_id', $v['area_id']);
        //     $lyjd_zhou[$k]['desc'] = $domainInfo['desc'];

        //     $subIds = $this->area->getColumn(['area_parent_id' => $v['area_id']], 'area_id');
        //     $lyjd_zhou[$k]['sub'] = $this->domain->getLists(['zone_id' => ['in', $subIds]], '', 'id,title,domain,zone_id');
        // }
        
        $catId = 35;
        $map1['catId'] = $catId;
        $lywhMap['catId'] = array('in','35,36,37,56');
        $lyjd_zhou = $this->getDomainTree($this->aid);
        foreach ($lyjd_zhou as $k => $v) {
            $domainInfo = get_domain('zone_id', $v['area_id']);
            $lyjd_zhou[$k]['desc'] = $domainInfo['desc'];
            $lyjd_zhou[$k]['sup'] = $this->databasefw
                ->name('article')
                ->where(['status'=>1,'catId'=>$catId,'aid'=>$v['area_id']])
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        }
        // halt($lyjd_zhou);
        $this->assign('lyjd_zhou',$lyjd_zhou);

        //创新创业(频道页)
        //创新创业(子栏目所有文章)
        $cxcyMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $cxcyMap['catId'] = array('in','38,39,41,42');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxcyMap;
        $cxcy = $this->databasefw
                ->name('article')
                ->where($cxcyMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxcy',$cxcy);
        //园区介绍
        $catId = 38;
        $cxcyMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxcyMap;
        $cxcyYqjs = $this->databasefw
                ->name('article')
                ->where($cxcyMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxcyYqjs',$cxcyYqjs);
        //州级-园区介绍
        $zhou_cxcyYqjs = $this->databasefw
                ->name('article')
                ->where(['status'=>1,'catId'=>$catId,'aid'=>1])
                // ->whereOr(function ($q) use($map1) {
                //         $q->where($map1);
                //     })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('zhou_cxcyYqjs',$zhou_cxcyYqjs);
        //入驻企业
        $catId = 40;
        $cxcyMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxcyMap;
        $cxcyRzqy = $this->databasefw
                ->name('article')
                ->where($cxcyMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxcyRzqy',$cxcyRzqy);
        //园区新闻
        $catId = 41;
        $cxcyMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxcyMap;
        $cxcyYqxw = $this->databasefw
                ->name('article')
                ->where($cxcyMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxcyYqxw',$cxcyYqxw);
        //创业服务
        $catId = 39;
        $cxcyMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $cxcyMap;
        $cxcyCyfw = $this->databasefw
                ->name('article')
                ->where($cxcyMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('cxcyCyfw',$cxcyCyfw);

        //电商协会(频道页)
        //电商协会(子栏目所有文章)
        $dsxhMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $dsxhMap['catId'] = array('in','42,43,44,45');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsxhMap;
        $dsxh = $this->databasefw
                ->name('article')
                ->where($dsxhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsxh',$dsxh);
        //协会介绍
        $catId = 42;
        $dsxhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsxhMap;
        $dsxhXhjs_zhou = $this->databasefw
                ->name('article')
                ->where($dsxhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsxhXhjs',$dsxhXhjs_zhou);
        $this->assign('dsxhXhjs_zhou',$dsxhXhjs_zhou);
        //交流活动
        $catId = 45;
        $dsxhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsxhMap;
        $dsxhJlhd = $this->databasefw
                ->name('article')
                ->where($dsxhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsxhJlhd',$dsxhJlhd);
        //会员服务
        $catId = 43;
        $dsxhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsxhMap;
        $dsxhHyfw = $this->databasefw
                ->name('article')
                ->where($dsxhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsxhHyfw',$dsxhHyfw);
        //入会企业
        $catId = 44;
        $dsxhMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsxhMap;
        $dsxhRhqy = $this->databasefw
                ->name('article')
                ->where($dsxhMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsxhRhqy',$dsxhRhqy);

        //示范交流(频道页)
        //示范交流(子栏目所有文章)
        $sfjlMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $sfjlMap['catId'] = array('in','46,47');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $sfjlMap;
        $sfjl = $this->databasefw
                ->name('article')
                ->where($sfjlMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('sfjl',$sfjl);
        //示范建设
        $catId = 46;
        $sfjlMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $sfjlMap;
        $sfjlSfjs = $this->databasefw
                ->name('article')
                ->where($sfjlMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('sfjlSfjs',$sfjlSfjs);
        //典型案例
        $catId = 47;
        $sfjlMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $sfjlMap;
        $sfjlDxal = $this->databasefw
                ->name('article')
                ->where($sfjlMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('sfjlDxal',$sfjlDxal);
        //halt($sfjlDxal);

        //人才培训(频道页)
        //人才培训(子栏目所有文章)
        $rcpxMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $rcpxMap['catId'] = array('in','1001,1002,1003,1004');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $rcpxMap;
        $rcpx = $this->databasepx
                ->name('article')
                ->where($rcpxMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('$rcpx',$rcpx);
        //培训计划
        $catId = 1001;
        $rcpxMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $rcpxMap;
        $rcpxPxjh = $this->databasepx
                ->name('article')
                ->where($rcpxMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('rcpxPxjh',$rcpxPxjh);
        //讲师介绍
        $catId = 1002;
        $rcpxMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $rcpxMap;
        $rcpxJsjs = $this->databasepx
                ->name('article')
                ->where($rcpxMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('rcpxJsjs',$rcpxJsjs);
        //学员风采
        $catId = 1003;
        $rcpxMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $rcpxMap;
        $rcpxXyfc = $this->databasepx
                ->name('article')
                ->where($rcpxMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('rcpxXyfc',$rcpxXyfc);
        //成果展示
        $catId = 1004;
        $rcpxMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $rcpxMap;
        $rcpxCgzs = $this->databasepx
                ->name('article')
                ->where($rcpxMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('rcpxCgzs',$rcpxCgzs);

        //电商扶贫(频道页)
        $dsfpMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $dsfpMap['catId'] = array('in','2001,2002,2003,2004,2005,2006');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfp = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfp',$dsfp);
        // halt($dsfp);
        //扶贫动态
        $catId = 2001;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpFpdt = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpFpdt',$dsfpFpdt);
        //扶贫案例
        $catId = 2006;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpFpal = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpFpal',$dsfpFpal);
        //扶贫品牌
        $catId = 2004;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpFppp = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpFppp',$dsfpFppp);
        //示范企业
        $catId = 2002;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpSfqy = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpSfqy',$dsfpSfqy);
        //扶贫示范户
        $catId = 2003;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpSfh = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpSfh',$dsfpSfh);
        //扶贫产品
        $catId = 2005;
        $dsfpMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $dsfpMap;
        $dsfpFpcp = $this->databasefp
                ->name('article')
                ->where($dsfpMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('dsfpFpcp',$dsfpFpcp);

        //品牌建设(频道页)
        $ppjsMap = [
            'status' => 1,
            'aid' => $aid,
        ];
        $ppjsMap['catId'] = array('in','3001,3002,3003,3004,3005');
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjs = $this->databasepp  
                ->name('article') 
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc') 
                ->select();
        $this->assign('ppjs',$ppjs);
        //halt($ppjs);
        //品牌简介
        $catId = 3001;
        $ppjsMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjsPpjj = $this->databasepp
                ->name('article')
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ppjsPpjj',$ppjsPpjj);
        //品牌形象
        $catId = 3002;
        $ppjsMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjsPpxx = $this->databasepp
                ->name('article')
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ppjsPpxx',$ppjsPpxx);
        //应用公示
        $catId = 3003;
        $ppjsMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjsYygs = $this->databasepp
                ->name('article')
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ppjsYygs',$ppjsYygs);
        //管理规定 
        $catId = 3004;
        $ppjsMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjsGlgd = $this->databasepp
                ->name('article')
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ppjsGlgd',$ppjsGlgd);
        //案例展示
        $catId = 3005;
        $ppjsMap['catId'] = $catId;
        $this->map1 ? $map1['catId'] = $catId : $map1 = $ppjsMap;
        $ppjsAlzs = $this->databasepp
                ->name('article')
                ->where($ppjsMap)
                ->whereOr(function ($q) use($map1) {
                        $q->where($map1);
                    })
                ->order('sort asc,updatetime desc')
                ->select();
        $this->assign('ppjsAlzs',$ppjsAlzs);
        //halt( $ppjsPpjj);

    //轮播
        //州级-首页轮播
        $stateIndexBanner = Db::name('banner_item')->where(['banner_id'=>2,'status'=>1])->order('update_at desc')->select();
        $this->assign('stateIndexBanner', $stateIndexBanner);

        //鹤庆县-云鹤镇首页轮播
        $yhzhenIndexBanner = Db::name('banner_item')->where(['banner_id'=>3,'status'=>1])->order('update_at desc')->select();
        $this->assign('yhzhenIndexBanner', $yhzhenIndexBanner);

        //鹤庆县-云鹤镇-东升村首页轮播
        $dscunIndexBanner = Db::name('banner_item')->where(['banner_id'=>4,'status'=>1])->order('update_at desc')->select();
        $this->assign('dscunIndexBanner', $dscunIndexBanner);

    //友情链接
        //国务院部门网站-州级
        $gwybmLinks = Db::name('links_item')->where(['links_id'=>1,'status'=>1])->order('update_at desc')->select();
        $this->assign('gwybmLinks', $gwybmLinks);
        //各省市政府网站-州级
        $gsszfLinks = Db::name('links_item')->where(['links_id'=>2,'status'=>1])->order('update_at desc')->select();
        $this->assign('gsszfLinks', $gsszfLinks);
        //省级政府网站-州级
        $sjzfLinks = Db::name('links_item')->where(['links_id'=>3,'status'=>1])->order('update_at desc')->select();
        $this->assign('sjzfLinks', $sjzfLinks);
        //州市政府网站-州级
        $zszfLinks = Db::name('links_item')->where(['links_id'=>4,'status'=>1])->order('update_at desc')->select();
        $this->assign('zszfLinks', $zszfLinks);
        //云南高校网站-州级
        $yngxLinks = Db::name('links_item')->where(['links_id'=>5,'status'=>1])->order('update_at desc')->select();
        $this->assign('yngxLinks', $yngxLinks);
        //云南企业网站-州县级
        $ynqyLinks = Db::name('links_item')->where(['links_id'=>6,'status'=>1])->order('update_at desc')->select();
        $this->assign('ynqyLinks', $ynqyLinks);
        //新闻媒体网站-州县级
        $xwmtLinks = Db::name('links_item')->where(['links_id'=>7,'status'=>1])->order('update_at desc')->select();
        $this->assign('xwmtLinks', $xwmtLinks);
        //其他-州级
        $qitaLinks = Db::name('links_item')->where(['links_id'=>8,'status'=>1])->order('update_at desc')->select();
        $this->assign('qitaLinks', $qitaLinks);
        //县级政府网站-洱源县
        $xjzfLinks = Db::name('links_item')->where(['links_id'=>9,'status'=>1])->order('update_at desc')->select();
        $this->assign('xjzfLinks', $xjzfLinks);
        //halt($xwmtLinks);
    }
    
    public function _empty(){
        return $this->error('空操作，返回上次访问页面中...');
    }
}